package com.atwulidun.memento18;

// 需要被保存状态的类
public class Originator {
    // 描述
    private String des;
    // 状态
    private String state;

    public Originator(String des, String state) {
        this.des = des;
        this.state = state;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getDes() {
        return des;
    }

    // 根据当前的状态返回一个Memento对象
    public Memento save() {
        return new Memento(state);
    }

    // 根据Memento对象来恢复当前对象的状态
    public void recover(Memento memento) {
        state = memento.getState();
    }
}
